package facilius.controller.action.aula;

import facilius.model.ServiceLocator;
import facilius.model.pojo.Aula;
import facilius.model.pojo.Material;
import facilius.util.TrataData;
import java.io.File;
import org.apache.commons.fileupload.FileItem;
import org.mentawai.core.BaseAction;

/**
 *
 * @author Graciano
 */
public class AulaCreateAction extends BaseAction {

    @Override
    public String execute() throws Exception {
        String consequence = ERROR;
        try {
            Aula aula = new Aula();
            aula.setData(TrataData.stringToDate(input.getString("data")));
            aula.setDescricao(input.getString("descricao"));
            aula.setTitulo(input.getString("titulo"));
            aula.setTurma(ServiceLocator.getTurmaService().readById(input.getLong("turmaId")));
            ServiceLocator.getAulaService().create(aula);

            
            
            consequence = SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return consequence;
    }
}
